<template>
	<div>我是测试文件</div>
	<router-link to="/">Go to indexPage</router-link>
	<div>{{ testName }}</div>
	<div @click="handDelet">删除</div>
</template>

<script>
import {
	addPostCart,
	addGetCart,
	testPosts,
	testPuts,
	testDelete,
} from '../services/test'
import { onMounted } from 'vue'
export default {
	setup() {
		const testName = '测试变量'

		onMounted(async () => {
			const res = await addPostCart()
			console.log(res, 'POST请求成功')

			const res1 = await addGetCart({
				name: 'crb',
			})
			console.log(res1, 'GET请求成功')

			const res2 = await testPosts(
				JSON.stringify({
					title: 'foo',
					body: 'bar',
					userId: 1,
				})
			)
			console.log(res2, '在线接口POST传递参数请求成功')

			const res3 = await testPuts(
				JSON.stringify({
					id: 1,
					title: 'foo',
					body: 'bar',
					userId: 1,
				})
			)
			console.log(res3, '在线接口Put传递参数请求成功')
		})

		return {
			testName,
		}
	},
	methods: {
		async handDelet() {
			const res = await testDelete()
			console.log(res, '在线接口删除成功')
		},
	},
}
</script>

<style scoped lang="less"></style>
